package org.cgc.obj;

import java.util.Date;
import java.util.Random;

public class DNA {
	
	private static Random r = new Random(new Date().getTime());
	private int[] dna;
	
	public DNA(int size) {
		dna = new int[size];
	}
	
	public DNA(int size, int maxColor) {
		dna = new int[size];
		for(int i = 0; i < size; i++) {
			dna[i] = i%maxColor;
		}
		
		int n = r.nextInt(size);
		for(int i = 0; i < n; i++) {
			int v1 = r.nextInt(size);
			int v2 = r.nextInt(size);
			int temp = dna[v1];
			dna[v1] = dna[v2];
			dna[v2] = temp;
		}
	}
	
	public int getSize() {
		return dna.length;
	}
	
	public int getGene(int i) {
		return dna[i];
	}
	
	public void setGene(int i, int value) {
		dna[i] = value;
	}
}
